"""
@author: 江同学呀
@file: setup.py
@date: 2023/9/5 21:16
@desc: 
"""
import compileall

from setuptools import setup, find_packages

compileall.compile_dir("./espc")

with open("README.md", "r", encoding="utf-8") as f:
    long_description = f.read()


setup(
    name="ESPrivyCouncil",  # 应用名
    version="2.0.0",  # 版本号
    url="https://gitee.com/jiangtongxueya/ESPrivyCouncil.git",
    author="江同学呀",
    author_email="1261275789@qq.com",
    packages=find_packages(),  # 包括在安装包内的 Python 包，此处表示my_demo目录下所有文件
    description="ElasticSearch的orm工具库",
    long_description=long_description,
    license="MIT",
    keywords=["python", "elasticsearch", "es", "orm"],
    # zip_safe=True,
    python_requires=">=3",  # depand on python version
    install_requires=[
        'elasticsearch',
        'loguru',
    ],
    # options={
    #     "build_ext": {"compile_pyc": True},
    #     "bdist_wheel": {"universal": True},
    # },
    package_data={"": ["espc/*.pyc"]},
    exclude_package_data={"": ["espc/*.py"]},
    classifiers=[
        # 发展时期,常见的如下
        #   3 - Alpha
        #   4 - Beta
        #   5 - Production/Stable
        'Development Status :: 3 - Alpha',

        # 开发的目标用户
        'Intended Audience :: Developers',

        # 属于什么类型
        'Topic :: Software Development :: Build Tools',

        # 表示包的许可证已被开放源代码计划（OSI）批准，例如MIT许可证。
        'License :: OSI Approved :: MIT License',
        # 目标 Python 版本
        'Programming Language :: Python :: 3.9',
        'Operating System :: OS Independent',
    ]
)


# import shutil
# import os
# from setuptools import setup
# # from distutils.core import setup
# from distutils.extension import Extension
# # from distutils.command.clean import clean
# # from Cython.Distutils import build_ext
#
# MODULE_NAME = "ESPrivyCouncil"  # 给项目名字
# SRC_DIR = "espc"  # 要加密代码的目录，个人倾向于把源码统一放在src文件夹下
# IGNORE_FILES = ["__init__.py"]  # 一般不对该文件加密
#
#
# # 对src文件夹下文件进行遍历，找到以py结尾的文件
# def traverse_path(dir, files=None, folders=None, extension_list=('py',)):
#     if folders is None:
#         folders = []
#     if files is None:
#         files = []
#     folders.append(dir)
#     for file in os.listdir(dir):
#         path = os.path.join(dir, file)
#         if os.path.isfile(path):
#             if '.' in path:
#                 _, extension = path.rsplit('.', 1)
#                 if extension.lower() in extension_list and file not in IGNORE_FILES:
#                     files.append(path)
#         elif os.path.isdir(path):
#             traverse_path(path, files, folders, extension_list)
#
#
# # ex_files参数可以支持不在src文件夹下的文件进行加密
# def get_extensions(ex_files=[]):
#     py_files = ex_files
#     traverse_path(SRC_DIR, files=py_files)  # traverse_path函数对py_files进行更新
#     ext_names = map(lambda x: x.replace(os.path.sep, '.')[:-3], py_files)
#
#     def make_extension(ext_name):
#         ext_path = ext_name.replace('.', os.path.sep) + '.py'
#         return Extension(ext_name, [ext_path], include_dirs=['.'])
#
#     extensions = map(lambda x: make_extension(x), ext_names)
#     return list(extensions)
#
#
# # ex_folders参数可以支持不在src文件夹下的文件进行加密
# def get_packages(ex_folders=[]):
#     folders = ex_folders
#     traverse_path(SRC_DIR, folders=folders)  # traverse_path对folders进行更新
#     packages = map(lambda x: x.replace('/', '.'), folders)
#     return list(packages)
#
#
# # # 对加密后的py，pyc和c文件进行清除
# # class CleanCode(object):
# #
# #     def clean_build(self, distribution):
# #         clean_command = clean(distribution)
# #         clean_command.all = True
# #         clean_command.finalize_options()
# #         clean_command.run()
# #
# #     def delete_source_code(self, target_dir):
# #         source_file_list = []
# #         traverse_path(target_dir, files=source_file_list, extension_list=('py', 'pyc', 'c'))
# #         for source_file in source_file_list:
# #             if os.path.basename(source_file) not in IGNORE_FILES:
# #                 os.remove(source_file)
# #
# #     def copy_so(self, build_path, source_code_path):
# #         self._copy_so(build_path, build_path, source_code_path)
# #
# #     def _copy_so(self, target_dir, build_base_dir, target_base_dir):
# #         for file in os.listdir(target_dir):
# #             path = os.path.join(target_dir, file)
# #             if os.path.isfile(path) and path.endswith('.so'):
# #                 new_path = path.replace(build_base_dir, target_base_dir)
# #                 shutil.copyfile(path, new_path)
# #             elif os.path.isdir(path):
# #                 self._copy_so(path, build_base_dir, target_base_dir)
# #
# #
# # # 继承Cython的build_ext类
# # class CustomBuildExt(build_ext, CleanCode):
# #
# #     def run(self):
# #         build_ext.run(self)
# #
# #         source_code_path = SRC_DIR
# #         build_path = os.path.join(self.build_lib, SRC_DIR)
# #         self.copy_so(build_path, source_code_path)
# #         self.clean_build(self.distribution)
# #         self.delete_source_code(source_code_path)
#
#
# ext_modules = get_extensions()
#
# setup(
#     name=MODULE_NAME,
#     packages=get_packages(),
#     ext_modules=ext_modules,
#     # cmdclass={'build_ext': CustomBuildExt}  # 自定义的CustomBuildExt
# )